﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<UnfriendlyFire.Models.Scenario>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create New Scenario
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        var armedForceParameterCount = 0;
        var siteParameterCount = 0;

        $(document).ready(function () {
            $("#addNewArmedForce").click(function () {
                var html = "<tr><td><input type='text' name='ArmedForceParameters[{1}].Name' value='force{1}'/></td></tr><tr id='newArmedForceInsertPoint'></tr>".replace("{1}", armedForceParameterCount.toString());
                $("#newArmedForceInsertPoint").replaceWith(html);
                armedForceParameterCount++;
            });
            $("#addNewSite").click(function () {
                var html = "<tr><td><input type='text' name='SiteParameters[{1}].Name' value='site{1}'/></td></tr><tr id='newSiteInsertPoint'></tr>".replace("{1}", siteParameterCount.toString());
                $("#newSiteInsertPoint").replaceWith(html);
                siteParameterCount++;
            });
        });
    </script>
    <h2>
        Create New Scenario</h2>
    <p>
        A scenario describes a conflict.
    </p>
    <% using (Html.BeginForm())
       {%>
    <%: Html.ValidationSummary(true) %>
    <table>
        <tr>
            <td class="editor-label">
                <%: Html.LabelFor(model => model.Name) %>
            </td>
            <td class="editor-field">
                <%: Html.TextBoxFor(model => model.Name) %>
                <%: Html.ValidationMessageFor(model => model.Name) %>
            </td>
        </tr>
        <tr>
            <td class="editor-label">
                <%: Html.LabelFor(model => model.Description) %>
            </td>
            <td class="editor-field">
                <%: Html.TextAreaFor(model => model.Description) %>
                <%: Html.ValidationMessageFor(model => model.Description) %>
            </td>
        </tr>
        <tr>
            <td class="editor-label">
                <%: Html.LabelFor(model => model.Icon) %>
            </td>
            <td class="editor-field">
                <%: Html.TextBoxFor(model => model.Icon) %>
                <%: Html.ValidationMessageFor(model => model.Icon) %>
            </td>
        </tr>
        <tr>
            <td class="editor-label">
                Armed Forces
            </td>
            <td>
                <table>
                    <tr id="newArmedForceInsertPoint">
                    </tr>
                    <tr>
                        <td id="addNewArmedForce">
                            Add new...
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="editor-label">
                Sites
            </td>
            <td>
                <table>
                    <tr id="newSiteInsertPoint">
                    </tr>
                    <tr>
                        <td id="addNewSite">
                            Add new...
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <input type="submit" value="Create Scenario" />
            </td>
        </tr>
    </table>
    <% } %>
    <div>
        <%: Html.ActionLink("Back to Scenarios", "Index") %>
    </div>
</asp:Content>
